package com.gobygang.client.map;



import java.util.logging.Level;
import java.util.logging.Logger;

import com.gobygang.client.Session;
import com.gobygang.client.Session.UserAgent;
import com.gobygang.client.Text;
import com.gobygang.client.suggest.AddressOracle;
import com.gobygang.client.uibinder.Alert;
import com.gobygang.client.uibinder.TaxiGangMapPanel;
import com.gobygang.shared.RouteInfo;
import com.gobygang.shared.TaxiGangInfo;
import com.gobygang.shared.TaxiGanguserInfo;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.geolocation.client.Position.Coordinates;
import com.google.gwt.maps.client.InfoWindow;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapType;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.Maps;
import com.google.gwt.maps.client.control.ControlAnchor;
import com.google.gwt.maps.client.control.ControlPosition;
import com.google.gwt.maps.client.control.SmallMapControl;
import com.google.gwt.maps.client.event.MarkerDragEndHandler;
import com.google.gwt.maps.client.geocode.Geocoder;
import com.google.gwt.maps.client.geocode.LatLngCallback;
import com.google.gwt.maps.client.geocode.LocationCallback;
import com.google.gwt.maps.client.geocode.Placemark;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.geom.LatLngBounds;
import com.google.gwt.maps.client.overlay.Icon;
import com.google.gwt.maps.client.overlay.Marker;
import com.google.gwt.maps.client.overlay.MarkerOptions;
import com.google.gwt.maps.client.overlay.Polyline;
import com.google.gwt.maps.client.overlay.PolylineOptions;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SimplePanel;

/**
 * Provides responses for queries made to the SuggestBox
 */

public class NavigatorWidget   {
	Logger logger = Logger.getLogger("NameOfYourLogger");


	private SearchView searchView;
	private Session session;
	private MapWidget map;
	private Geocoder geocoder;

	private Marker startMarker;
	private Marker destinationMarker;
	private Marker suggestionStartMarker;
	private Marker suggestionDestinationMarker;
	private MarkerOptions startMarkerOptions;
	private MarkerOptions destinationMarkerOptions;

	private Polyline startPolyline;
	private Polyline  destinationPolyline;
	private Polyline  startDestinationPolyline;
	private Polyline  suggestionStartDestinationPolyline;

	private static final String TAXIGANGKEY = "ABQIAAAAlXsDnvI0qCB3wDHyWfH09RR-bADaRizs_ZQV_sOQa-_Avxns4BQZ7IdmxyYB_0W_PuNcnElVhbgjJA";
	private static final String INCUBATORKEY ="ABQIAAAAlXsDnvI0qCB3wDHyWfH09RS6NsOfqVa9c0m19d8kOVETx5V2oxSvQbn3mNQ6MCoxqYIFF3V9Abuhrg";

	private static NavigatorWidget instance = new NavigatorWidget();;
	public static NavigatorWidget getInstance(){
		return instance;
	}
	private NavigatorWidget() {
	}
	
	public void setSearchView(SearchView searchView){
		this.searchView = searchView;
	}

	public void showMap(final TaxiGangMapPanel panel, final Command cmd){
		logger.info("show map1:");
		String key = TAXIGANGKEY;
		if (Session.getInstance().getIsIncubator()){
			key = INCUBATORKEY;
		}
		Maps.loadMapsApi(key, "2", false, new Runnable() {
			public void run() {
				initialize(panel.getPanel());
				if (cmd != null){
					cmd.execute();
				}
			}
		});

	}



	public void resetSuggestion(){
		if (map==null)return;
		//		Polyline[] polylineList = {startPolyline, destinationPolyline, startDestinationPolyline};
		//		for (Polyline polyline : polylineList){
		//			if (polyline != null){
		//				map.removeOverlay(polyline);
		//				polyline = null;
		//			}
		//		}
		map.getInfoWindow().setVisible(false);
		if (startPolyline != null){
			map.removeOverlay(startPolyline);
			startPolyline = null;
		}

		if (destinationPolyline != null){
			map.removeOverlay(destinationPolyline);
			destinationPolyline = null;
		}

		//		if (startDestinationPolyline != null){
		//			map.removeOverlay(startDestinationPolyline);
		//		}

		if (suggestionStartMarker!= null){
			map.removeOverlay(suggestionStartMarker);
			suggestionStartMarker = null;
		}

		if (suggestionStartDestinationPolyline!= null){
			map.removeOverlay(suggestionStartDestinationPolyline);
			suggestionStartDestinationPolyline = null;
		}

		if (suggestionStartMarker!= null){
			map.removeOverlay(suggestionStartMarker);
			suggestionStartMarker = null;
		}

		if (suggestionDestinationMarker!= null){
			map.removeOverlay(suggestionDestinationMarker);
			suggestionDestinationMarker = null;
		}

		updateConnectionLine();

	}

	public void displayStartDestination(TaxiGangInfo taxiganginfo){
		if (startMarker != null){
			taxiganginfo.setStartLat(startMarker.getLatLng().getLatitude());
			taxiganginfo.setStartLng(startMarker.getLatLng().getLongitude());
		}
		if (destinationMarker != null){
			taxiganginfo.setDestinationLat(destinationMarker.getLatLng().getLatitude());
			taxiganginfo.setDestinationLng(destinationMarker.getLatLng().getLongitude());
		}
	}


	public void makeSuggestion(TaxiGangInfo taxiganginfo){
		if (startDestinationPolyline != null){
			map.removeOverlay(startDestinationPolyline);
			startDestinationPolyline= null;
		}

		if (taxiganginfo != null){
			//session.setTaxiGangInfo(taxiganginfo);

			resetSuggestion();

			LatLng startLatLng = LatLng.newInstance(taxiganginfo.getStartLat(), taxiganginfo.getStartLng());
			LatLng destinationLatLng = LatLng.newInstance(taxiganginfo.getDestinationLat(), taxiganginfo.getDestinationLng());


			LatLng[] startline = new LatLng[2];
			startline[0] = LatLng.newInstance(taxiganginfo.getStartLat(), taxiganginfo.getStartLng());
			startline[1] = LatLng.newInstance(taxiganginfo.getStartLat(),taxiganginfo.getStartLng());
			PolylineOptions plo = PolylineOptions.newInstance(true, false);
			startPolyline = new Polyline(startline, "#FF0000", 2, 1.0, plo);
			map.addOverlay(startPolyline);

			LatLng[] destinationline = new LatLng[2];
			destinationline[0] = LatLng.newInstance(taxiganginfo.getDestinationLat(), taxiganginfo.getDestinationLng());
			destinationline[1] = LatLng.newInstance(taxiganginfo.getDestinationLat(),taxiganginfo.getDestinationLng());
			destinationPolyline = new Polyline(destinationline, "#FF0000", 2, 1.0, plo);
			map.addOverlay(destinationPolyline);

			LatLng[] suggestionLine = new LatLng[2];
			suggestionLine[0] = LatLng.newInstance(taxiganginfo.getStartLat(), taxiganginfo.getStartLng());
			suggestionLine[1] = LatLng.newInstance(taxiganginfo.getDestinationLat(), taxiganginfo.getDestinationLng());
			suggestionStartDestinationPolyline = new Polyline(suggestionLine, "#FF0000", 2, 1.0, plo);
			map.addOverlay(suggestionStartDestinationPolyline);

			if (suggestionStartMarker== null){
				MarkerOptions suggestionMarkerOptions = MarkerOptions.newInstance();
				suggestionMarkerOptions.setDraggable(false);
				Icon icon = Icon.newInstance(Icon.getDefaultIcon());
				icon.setImageURL("images/taxi_green.png");

				suggestionMarkerOptions.setIcon(icon);

				suggestionStartMarker = new Marker(startLatLng,suggestionMarkerOptions);
				map.addOverlay(suggestionStartMarker);

			} else {
				suggestionStartMarker.setLatLng(startLatLng);
			}

			if (suggestionDestinationMarker== null){
				MarkerOptions suggestionMarkerOptions = MarkerOptions.newInstance();
				suggestionMarkerOptions.setDraggable(false);
				Icon icon = Icon.newInstance(Icon.getDefaultIcon());
				icon.setImageURL("images/taxi_red.png");

				suggestionMarkerOptions.setIcon(icon);
				suggestionDestinationMarker = new Marker(destinationLatLng,suggestionMarkerOptions);
				map.addOverlay(suggestionDestinationMarker);
			} else {
				suggestionDestinationMarker.setLatLng(destinationLatLng);
			}
			//map.checkResizeAndCenter();
			rebound(suggestionStartMarker, suggestionDestinationMarker);
		}
	}


	private void initialize(SimplePanel taxiGangMapPanel){
		logger.info("initialize map");
		session = Session.getInstance();
		//Window.alert("initialize:start");
		if (Maps.isBrowserCompatible()) {

			map = new MapWidget(LatLng.newInstance(0, 0), 2);
			//map.setSize(Window.getClientWidth()-12+"px", "100%");

			map.removeMapType(MapType.getSatelliteMap());
			map.removeMapType(MapType.getHybridMap());

			//map.setDraggable(false);

			//			String height = (LayoutConstants.getInstance().getWindowHeight() - (LayoutConstants.getInstance().getTitlePanelHeight() + LayoutConstants.getInstance().getMapButtonPanelHeight()))+"px";
			//			String width = LayoutConstants.getInstance().getWindowWidth()+"px";

			String width="522px";
			String height="388px";

			//			logger.info("width:"+Window.getClientWidth());
			//			logger.info("width:"+Window.getClientHeight());
			map.setSize(width, height);
			//Window.alert("show map:"+width);

			// Add some controls for the zoom level
			geocoder = new Geocoder();
			if (
					session.getUserAgent() == UserAgent.PC || 
					session.getUserAgent() == UserAgent.PC_WEBKIT || 
					session.getUserAgent() == UserAgent.FB ||
					session.getUserAgent() == UserAgent.FB_WEBKIT
			){
				map.addControl(new SmallMapControl(),new ControlPosition(ControlAnchor.TOP_LEFT,0,0));
			}
			if (taxiGangMapPanel!=null){
				taxiGangMapPanel.add(map);
			}
			setStartCity();

			AddressOracle.setGeocoder();

		}

	}



	public void setStartCity(){
		String startCity = session.getStartCity().trim();
		if (startCity.length()!=0){
			TaxiGanguserInfo taxiGanguserInfo = new TaxiGanguserInfo();
			taxiGanguserInfo.setCityList(new String[] {startCity});
			session.setTaxiGangUserInfo(taxiGanguserInfo);
			if (session.getTaxiGangUserInfo() != null){
				if (session.getTaxiGangUserInfo().getCityList().length > 0){
					startCity = session.getTaxiGangUserInfo().getCityList()[0];
					logger.info("setStartCity:city ="+startCity);
					session.getSearchTaxiGangInfo().setStart(startCity);
					createStartMarker(startCity, false);
				} 
			} else {
				logger.log(Level.FINE,"session.getTaxiGangUserInfo()==null");				
			}
		}

	}

	public void createStartMarker(String start, boolean setAddress) {
		logger.info("createStartMarker:"+start+" ");

		if (start != null){
			session.getSearchTaxiGangInfo().setStart(start);
		} 

		final String searchAddress = start;
		createStartMarker(searchAddress, (Command)null, setAddress);
	}

	private void alertAddressNotFound(String address){
		String addressNotFound = address + Text.t.addressCouldNotBeFound();
		Alert.alert(null, "Whoops!", addressNotFound, false,"200px");		
	}

	private void alertPointNotFound(){
		String addressNotFound = Text.t.pointCouldNotBeFound();
		Alert.alert(null, "Whoops!", addressNotFound, false,"422px");		
	}

	public void createStartMarker(final String address, final Command cmd, final boolean setAddress){
		logger.info("createStartMarker:"+address+" geocoder exists="+(geocoder != null));

		if (geocoder != null){
			geocoder.getLatLng(address, new LatLngCallback() {
				public void onFailure() {
					alertAddressNotFound(address);
				}

				public void onSuccess(LatLng point) {
					createStartMarker(point,cmd,setAddress);
					//					if (startMarker==null){
					//						startMarkerOptions = MarkerOptions.newInstance();
					//						startMarkerOptions.setDraggable(true);
					//						Icon icon = Icon.newInstance(Icon.getDefaultIcon());
					//						icon.setImageURL("images/green-dot.png");
					//
					//						startMarkerOptions.setIcon(icon);
					//						startMarker = new Marker(point,startMarkerOptions);
					//						map.addOverlay(startMarker);
					//						startMarker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
					//							public void onDragEnd(MarkerDragEndEvent event) {
					//								getLoocationOfStartMarker(cmd,true);
					//								updateConnectionLine();
					//							}
					//
					//						});
					//					} else {
					//						startMarker.setLatLng(point);
					//					}
					//
					//					getLoocationOfStartMarker(cmd,setAddress);
					//
					//					//				String postalCode = startMarker.getgetCountry()+place.getPostalCode();
					//					//				session.setPostalCode(postalCode);
					//
					//					//				session.getSearchTaxiGangInfo().setStartLat(startMarker.getLatLng().getLatitude());
					//					//				session.getSearchTaxiGangInfo().setStartLng(startMarker.getLatLng().getLongitude());
					//
					//					//update();
					//
					//
					//					//
					//					LatLng startLatLng = startMarker.getLatLng();
					//					//					if (session.getUserAgent()==UserAgent.FB || session.getUserAgent()==UserAgent.FB_WEBKIT ){
					//					//						startLatLng = LatLng.newInstance(startLatLng.getLatitude(), startLatLng.getLongitude()+0.01); //shift a bit left in fb
					//					//					}
					//					map.setCenter(startLatLng, 13);
					//
				}
			});
		}
	}

	public void createStartMarker(Coordinates c,final Command cmd, boolean setAddress){
		LatLng latLng = LatLng.newInstance(c.getLatitude(), c.getLongitude());
		createStartMarker(latLng,cmd, setAddress);
	}

	private void createStartMarker(LatLng point,final Command cmd, boolean setAddress){
		if (startMarker==null){
			startMarkerOptions = MarkerOptions.newInstance();
			startMarkerOptions.setDraggable(true);
			Icon icon = Icon.newInstance(Icon.getDefaultIcon());
			icon.setImageURL("images/green-dot.png");

			startMarkerOptions.setIcon(icon);
			startMarker = new Marker(point,startMarkerOptions);
			map.addOverlay(startMarker);
			startMarker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
				public void onDragEnd(MarkerDragEndEvent event) {
					getLoocationOfStartMarker(cmd,true);
					updateConnectionLine();
				}

			});
		} else {
			startMarker.setLatLng(point);
		}

		getLoocationOfStartMarker(cmd,setAddress);

		//				String postalCode = startMarker.getgetCountry()+place.getPostalCode();
		//				session.setPostalCode(postalCode);

		//				session.getSearchTaxiGangInfo().setStartLat(startMarker.getLatLng().getLatitude());
		//				session.getSearchTaxiGangInfo().setStartLng(startMarker.getLatLng().getLongitude());

		//update();


		//
		LatLng startLatLng = startMarker.getLatLng();
		//					if (session.getUserAgent()==UserAgent.FB || session.getUserAgent()==UserAgent.FB_WEBKIT ){
		//						startLatLng = LatLng.newInstance(startLatLng.getLatitude(), startLatLng.getLongitude()+0.01); //shift a bit left in fb
		//					}
		map.setCenter(startLatLng, 13);

	}


	private void getLoocationOfStartMarker(final Command cmd, final boolean setAddress){
		geocoder.getLocations(startMarker.getLatLng(), new LocationCallback() {
			public void onFailure(int statusCode) {
				alertPointNotFound();
			}

			public void onSuccess(JsArray<Placemark> locations) {
				try{
					Placemark place = locations.get(0);
					String postalCode = place.getCountry()+place.getPostalCode();
					//Window.alert(postalCode);
					session.setPostalCode(postalCode);
					String address = place.getAddress();
					//startMarker.setLatLng(place.getPoint());
					if (setAddress){
						searchView.setStart(address);
					}else{
						//searchView.setStartCity(city);
					}

					session.getSearchTaxiGangInfo().setStart(place.getAddress());
					session.getSearchTaxiGangInfo().setStartLat(startMarker.getLatLng().getLatitude());
					session.getSearchTaxiGangInfo().setStartLng(startMarker.getLatLng().getLongitude());
					if (cmd != null){
						cmd.execute();	
					}
					updateConnectionLine();
				} catch (Exception ex){
					alertAddressNotFound("");
				}

			}
		});

	}

	private void showError(String address){
		//logger.error("Error in NavigatorWidget address:"+address);
		Alert.alert(null, "Problem", Text.t.sorryProblem(), false,"422px");
	}

	private void getLoocationOfDestinationMarker(final Command cmd, final boolean setAddress){
		geocoder.getLocations(destinationMarker.getLatLng(), new LocationCallback() {
			public void onFailure(int statusCode) {
				alertPointNotFound();
			}

			public void onSuccess(JsArray<Placemark> locations) {
				try{
					Placemark place = locations.get(0);
					String addressCity = place.getAddress();
					//startMarker.setLatLng(place.getPoint());
					if (setAddress){
						searchView.setDestination(addressCity);
					}

					session.getSearchTaxiGangInfo().setDestination(place.getAddress());
					if (startMarker != null){
						session.getSearchTaxiGangInfo().setStartLat(startMarker.getLatLng().getLatitude());
						session.getSearchTaxiGangInfo().setStartLng(startMarker.getLatLng().getLongitude());
					}
					if (cmd != null){
						cmd.execute();
						if (session.getRef()!=null){
							RouteInfo partnerInfo = session.getRoute();
							
							//String htmlString = "<span style=\"padding: 0px; text-align:left\" align=\"left\"><h2>Atomic Cafe</h2></span>"  ;
							
							map.getInfoWindow().open(destinationMarker.getLatLng(),
									//new InfoWindowContent("Atomic Cafe"));
									//new InfoWindowContent(new HTMLPanel(htmlString)));
									new InfoWindowContent(new Label(partnerInfo.getName())));
						}

					}
					updateConnectionLine();
				} catch (Exception ex){
					showError("getLoocationOfDestinationMarker:"+destinationMarker.getLatLng());
				}

			}
		});

	}

	//	private void setInitialSartMarker(Coordinates coords){
	//		startMarkerOptions = MarkerOptions.newInstance();
	//		startMarkerOptions.setDraggable(true);
	//		Icon icon = Icon.newInstance(Icon.getDefaultIcon());
	//		icon.setImageURL("images/green-dot.png");
	//
	//		startMarkerOptions.setIcon(icon);
	//		LatLng point = LatLng.newInstance(coords.getLatitude(), coords.getLongitude());
	//		startMarker = new Marker(point,startMarkerOptions);
	//		Window.alert("lat:"+coords.getLatitude());
	//		map.addOverlay(startMarker);
	//
	//	}

	public void createDestinationMarker(String destination, boolean setAddress, Command cmd) {
		logger.info("createDestinationMarker:"+destination);

		if (destination != null && destination.trim().length() > 0){
			session.getSearchTaxiGangInfo().setDestination(destination);
			createDestinationMarker(destination,cmd,setAddress);
		} 

	}

	public void createDestinationMarker(final String address, final Command cmd, final boolean setAddress) {
		logger.info("createDestinationMarker:"+address+" geocoder exists="+(geocoder != null));

		geocoder.getLatLng(address, new LatLngCallback() {
			public void onFailure() {
				alertAddressNotFound(address);
			}

			public void onSuccess(LatLng point) {
				createDestinationMarker(point,cmd,setAddress);
			}
		});
	}

	public void createDestinationMarker(double lat, double lng,final Command cmd, boolean setAddress){
		LatLng latLng = LatLng.newInstance(lat, lng);
		createDestinationMarker(latLng,cmd, setAddress);
	}

	private void createDestinationMarker(LatLng point,final Command cmd, boolean setAddress){
		if (destinationMarker==null){
			destinationMarkerOptions = MarkerOptions.newInstance();
			destinationMarkerOptions.setDraggable(true);
			Icon icon = Icon.newInstance(Icon.getDefaultIcon());
			icon.setImageURL("images/red-dot.png");

			destinationMarkerOptions.setIcon(icon);
			destinationMarker = new Marker(point,destinationMarkerOptions);
			map.addOverlay(destinationMarker);

			destinationMarker.setDraggingEnabled(true);
			destinationMarker.addMarkerDragEndHandler(new MarkerDragEndHandler() {
				public void onDragEnd(MarkerDragEndEvent event) {
					geocoder.getLocations(destinationMarker.getLatLng(), new LocationCallback() {
						public void onFailure(int statusCode) {
							alertPointNotFound();
						}

						public void onSuccess(JsArray<Placemark> locations) {
							Placemark place = locations.get(0);
							String addressCity = place.getAddress();
							String address = addressCity.substring(0, addressCity.indexOf(','));
							String city = addressCity.substring(addressCity.indexOf(',')+1);
							//startMarker.setLatLng(place.getPoint());

							logger.info("destination:"+place.getAddress()+":"+destinationMarker.getLatLng().getLatitude()+":"+destinationMarker.getLatLng().getLongitude());

							searchView.setDestination(addressCity);

							session.getSearchTaxiGangInfo().setDestination(place.getAddress());
							session.getSearchTaxiGangInfo().setDestinationLat(destinationMarker.getLatLng().getLatitude());
							session.getSearchTaxiGangInfo().setDestinationLng(destinationMarker.getLatLng().getLongitude());
							updateConnectionLine();
							
							InfoWindow win = map.getInfoWindow();
							

						}
					});
				}

			});


		} else {
			//logger.error("destinationMarker not null");
			destinationMarker.setLatLng(point);
		}
		session.getSearchTaxiGangInfo().setDestinationLat(destinationMarker.getLatLng().getLatitude());
		session.getSearchTaxiGangInfo().setDestinationLng(destinationMarker.getLatLng().getLongitude());

		getLoocationOfDestinationMarker(cmd, setAddress);
		updateConnectionLine();

	}
	public void reset(){
		startMarker = null;
		destinationMarker = null;
		if (startDestinationPolyline != null){
			map.removeOverlay(startDestinationPolyline);
		}
	}


	public void rebound(Marker startMarker, Marker destMarker){
		map.checkResizeAndCenter();
		LatLngBounds bounds = LatLngBounds.newInstance();
		bounds.extend(startMarker.getLatLng());
		bounds.extend(destMarker.getLatLng());
		int zoomLevel = map.getBoundsZoomLevel(bounds);
		map.setCenter(bounds.getCenter(), zoomLevel);
	}

	private void updateConnectionLine(){
		//if (!sessionEstablished){
		if (startDestinationPolyline != null){
			map.removeOverlay(startDestinationPolyline);
		}

		logger.info("update:"+(startMarker!=null && destinationMarker!=null));
		if (startMarker != null && destinationMarker != null){
			//add startDestination polyline
			LatLng[] startDestinationline = new LatLng[2];
			startDestinationline[0] = LatLng.newInstance(startMarker.getLatLng().getLatitude(), startMarker.getLatLng().getLongitude());
			startDestinationline[1] = LatLng.newInstance(destinationMarker.getLatLng().getLatitude(), destinationMarker.getLatLng().getLongitude());
			PolylineOptions plo = PolylineOptions.newInstance(true, false);
			startDestinationPolyline = new Polyline(startDestinationline, "#FF0000", 4, 1.0, plo);
			map.addOverlay(startDestinationPolyline);
			rebound(startMarker, destinationMarker);

		}

	}





	//	private void drawCircle(long lat, long lng, long radius, int stroke, String sColor) {
	//
	//		// Degrees to radians
	//		double d2r = Math.PI / 180;
	//		// Radians to degrees
	//		double r2d = 180 / Math.PI;
	//		// Earth radius is 3,963 miles
	//		double cLat = (radius / 3963) * r2d;
	//		double cLng = cLat / Math.cos(lat * d2r);
	//
	//		// Store points in array
	//		LatLng[]  points = new LatLng[360];
	//
	//		// Calculate the points
	//		// Work around 360 points on circle
	//		for (int i=0; i < 360; i++) {
	//
	//			double theta = Math.PI * (i/16);
	//
	//			// Calculate next X point
	//			double circleX = lng + (cLng * Math.cos(theta));
	//			// Calculate next Y point
	//			double circleY = lat + (cLat * Math.sin(theta));
	//			// Add point to array
	//			points[i]=LatLng.newInstance(circleX, circleY);
	//
	//		};
	//
	//		// Add points to map
	//		//  map.addOverlay(new Polyline(points, sColor, stroke));
	//
	//	}


}